<template>
	<view>
		<navigator :url="'/pages/user-space/user-space?user_id='+ isUserid">
			<view class="p-2 flex align-center border-bottom border-light-secondary" hover-class="bg-light">
				<image :src="item.avatar" style="width: 100rpx;height: 100rpx;" class="rounded-circle mr-2"></image>
				<view class="flex flex-column flex-1">
					<text class="font-md text-dark">{{item.username}}</text>
					<view>
						<uni-badge :text="age_datetime" :type="user_sex[item.sex]['type']" size="small">
							<text :class="user_sex[item.sex]['classes']" class="iconfont text-white font-sm mr-1" style="margin-right: 5rpx;"></text>
						</uni-badge>
					</view>
				</view>
				<view class="uni-icon uni-icon-checkbox-filled" :class="{'text-main':item.isFollow,'text-light-muted':!item.isFollow}"></view>
			</view>
		</navigator>
	</view>
</template>

<script>
	import uniBadge from '@/components/uni-ui/uni-badge/uni-badge'
	export default{
		components:{
			uniBadge
		},
		props:{
			item:Object,
			index:Number
		},
		computed:{
			age_datetime(){
				if(this.item.age==="保密"){
					return "保密"
				}
				// 毫秒转化年
				let n = 3.1710e-11
				let stamp=new Date()-new Date(this.item.age)
				let age = Math.floor(stamp*n )
				
				return age<1 ? 1 :age
			},
			isUserid(){
				let user = this.item.user
				if(this.$store.state.userInfo.id == user){
					user = this.item.user_follow
				}
				return user ? user : this.item.id
			}
		},
		data(){
			return{
				// 0.无，1.女，2.男
				user_sex:{
					0:{
						type:'',
						classes:''
					},
					1:{
						type:'error',
						classes:'icon-nv'
					},
					2:{
						type:'primary',
						classes:'icon-nan'
					}
				}
			}
		}
	}
</script>

<style>
</style>
